﻿using System;
using System.Windows.Data;

namespace AnthStat.WPF.Applications.Converters
{
    [ValueConversion(typeof(string), typeof(bool))]
    public sealed class CurveTypeToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var newValue = value.ToString();

            if (newValue.Equals("p", StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var newValue = (bool)value;

            if (newValue)
            {
                return "P";
            }
            else
            {
                return "Z";
            }
        }
    }
}
